package com.elcl.util.viewutils;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;

import com.elcl.storage.ApplicationCache;

/**
 * Created by lichunlin on 17/1/27.
 */

public class RecycleViewUtils {

    //初始化view
    public static void initRecycleView(RecyclerView recyclerView) {
        recyclerView.setHasFixedSize(true);
        LinearLayoutManager layoutManager = new LinearLayoutManager(ApplicationCache.context);
        layoutManager.setOrientation(OrientationHelper.VERTICAL);

        //设置Item增加、移除动画
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        //添加分割线
        recyclerView.addItemDecoration(new DividerItemDecoration(
                ApplicationCache.context, DividerItemDecoration.VERTICAL));

        recyclerView.setLayoutManager(layoutManager);
    }


}
